#include "SMPPCancelBroadcastOptionalTLVs.hpp"

using namespace smpp::pdu;

CancelBroadcastOptionalTLVs::CancelBroadcastOptionalTLVs(
const BroadcastContentType *nBroadcastContentType,
const UserMessageReference *nUserMessageReference):
_BroadcastContentType(0),
_UserMessageReference(0){
	if(nBroadcastContentType)
		_BroadcastContentType = 
		new BroadcastContentType(*nBroadcastContentType);
	if(nUserMessageReference)
		_UserMessageReference = 
		new UserMessageReference(*nUserMessageReference);
}

CancelBroadcastOptionalTLVs::CancelBroadcastOptionalTLVs(
const CancelBroadcastOptionalTLVs &nCancelBroadcastOptionalTLVs):
_BroadcastContentType(0),
_UserMessageReference(0){
	if(nCancelBroadcastOptionalTLVs.getBroadcastContentType())
		_BroadcastContentType = new BroadcastContentType(
		*nCancelBroadcastOptionalTLVs.getBroadcastContentType());
	if(nCancelBroadcastOptionalTLVs.getUserMessageReference())
		_UserMessageReference = new UserMessageReference(
		*nCancelBroadcastOptionalTLVs.getUserMessageReference());
}

CancelBroadcastOptionalTLVs::~CancelBroadcastOptionalTLVs(){
	if(_BroadcastContentType)
		delete _BroadcastContentType;
	if(_UserMessageReference)
		delete _UserMessageReference;
}

void CancelBroadcastOptionalTLVs::setBroadcastContentType(
	const BroadcastContentType *nBroadcastContentType){
	if(_BroadcastContentType){
		delete _BroadcastContentType;
		_BroadcastContentType = 0;
	}
	if(nBroadcastContentType)
		_BroadcastContentType = 
		new BroadcastContentType(*nBroadcastContentType);
}

const BroadcastContentType *
	CancelBroadcastOptionalTLVs::getBroadcastContentType() const{
		return _BroadcastContentType;
}

void CancelBroadcastOptionalTLVs::setUserMessageReference(
	const UserMessageReference *nUserMessageReference){
	if(_UserMessageReference){
		delete _UserMessageReference;
		_UserMessageReference = 0;
	}
	if(nUserMessageReference)
		_UserMessageReference = 
		new UserMessageReference(*nUserMessageReference);
}

const UserMessageReference *
	CancelBroadcastOptionalTLVs::getUserMessageReference() const{
	return _UserMessageReference;
}

const quint16 CancelBroadcastOptionalTLVs::getLength() const{
	quint16 length(0);
	if(_BroadcastContentType)
		length += 4 + _BroadcastContentType->getLength();
	if(_UserMessageReference)
		length += 4 + _UserMessageReference->getLength();
	return length;
}
